#pragma once

#ifdef __cplusplus
extern "C"
{
#endif

#ifndef _WIN32
#define TRANSCODE_API
#else
#define TRANSCODE_API __declspec(dllexport)
#endif

/* --------------------------------------------------------------------------- */
/* parameters for picture transcoder                                           */
/* ----------------------------------------------------------------------------*/
typedef struct PicTransParam
{
    int   threadCount;       /* max parallel task number: 1-128 */
    int   reserved[64];
} PicTransParam;

/* --------------------------------------------------------------------------- */
/* parameters for run a new transcode task                                     */
/* ----------------------------------------------------------------------------*/
typedef struct TaskParam
{
    char* pInputFile;        /* input file name */
    char* pOutputFile;       /* output jpeg file name */
    char* pThumbNailFile;    /* output thumbnail jpeg file name */
    int   ThumbNailWidth;    /* output thumbnail file width */
    int   nProfile;          /* jpeg encode profile: 0(default), 1(fast) */
    int   nQuailty;          /* jpeg encode quality: 0-100 */
    int   bSync;             /* synchronous transcode mode */
    int   reserved[64];
} TaskParam;

/**
 * ---------------------------------------------------------------------------
 * Function   : open a picture transcoder
 * Parameters :
 * [in]       : pParam - pointer to struct PicTransParam
 * Return     : handle of the transcoder, zero for failure
 * ---------------------------------------------------------------------------
 */
TRANSCODE_API void* TranscodeOpen(PicTransParam *pParam);

/**
 * ---------------------------------------------------------------------------
 * Function   : close the picture transcoder
 * Parameters :
 * [in]       : ctx - transcoder handle
 * Return     : 0(success), -1(failure)
 * ---------------------------------------------------------------------------
 */
TRANSCODE_API int TranscodeClose(void* ctx);

/**
 * ---------------------------------------------------------------------------
 * Function   : run a new picture transcode task
 * Parameters :
 * [in]       : ctx   - pointer to the transcoder handler
 * [in]       : task  - pointer to struct TaskParam
 * Return     : 0(success), -1(failure)
 * ---------------------------------------------------------------------------
 */
TRANSCODE_API int TranscodePutTask(void* ctx, TaskParam* task);

/**
 * ---------------------------------------------------------------------------
 * Function   : wait for all tasks to finish
 * Parameters :
 * [in]       : ctx   - pointer to the transcoder handler
 * Return     : 0(success), -1(failure)
 * ---------------------------------------------------------------------------
 */
TRANSCODE_API int TranscodeWaitTaskFinish(void* ctx);

/**
 * ---------------------------------------------------------------------------
 * Function   : set or get options for extension
 * Parameters :
 * [in]       : ctx   - pointer to the transcoder handler
 * [in]       : type  - option type
 * [in]       : pSet  - params to set
 * [out]      : pGet  - params to get
 * Return     : 0(success), -1(failure)
 * ---------------------------------------------------------------------------
 */
TRANSCODE_API int TranscodeOptions(void* ctx, int type, void* pSet, void* pGet);

#ifdef __cplusplus
}
#endif
